# plotly standard imports
import plotly.graph_objs as go
import chart_studio.plotly as py
# Cufflinks wrapper on plotly
import cufflinks
# Data science imports
import pandas as pd
import numpy as np
# Options for pandas
pd.options.display.max_columns = 30
# Display all cell outputs
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = 'all'
from plotly.offline import iplot, init_notebook_mode
cufflinks.go_offline(connected=True)
init_notebook_mode(connected=True)
# Set global theme
cufflinks.set_config_file(world_readable=True, theme='pearl')
from src.load_datasets import load_input_dataset
df = load_input_dataset()
df.head()
| timestamp | open | high | low | close | volume | |
|---|---|---|---|---|---|---|
| 0 | 1470844380000 | 579.00 | 579.00 | 579.00 | 579.00 | 1.000000 |
| 1 | 1470844440000 | 592.96 | 604.75 | 592.96 | 604.75 | 131.838200 |
| 2 | 1470844500000 | 604.75 | 604.75 | 600.00 | 600.00 | 89.437926 |
| 3 | 1470844620000 | 600.00 | 604.75 | 600.00 | 604.75 | 51.328200 |
| 4 | 1470844680000 | 604.75 | 604.75 | 604.75 | 604.75 | 4.586500 |
df.index = pd.to_datetime(df.pop('timestamp'), unit='ms')
df.head()
| open | high | low | close | volume | |
|---|---|---|---|---|---|
| timestamp | |||||
| 2016-08-10 15:53:00 | 579.00 | 579.00 | 579.00 | 579.00 | 1.000000 |
| 2016-08-10 15:54:00 | 592.96 | 604.75 | 592.96 | 604.75 | 131.838200 |
| 2016-08-10 15:55:00 | 604.75 | 604.75 | 600.00 | 600.00 | 89.437926 |
| 2016-08-10 15:57:00 | 600.00 | 604.75 | 600.00 | 604.75 | 51.328200 |
| 2016-08-10 15:58:00 | 604.75 | 604.75 | 604.75 | 604.75 | 4.586500 |
df[::60].iplot(subplots=True)
from src.prepare_datasets import add_indicators
df = add_indicators(df)
/usr/local/lib/python3.6/dist-packages/ta/trend.py:768: RuntimeWarning: invalid value encountered in double_scalars /usr/local/lib/python3.6/dist-packages/ta/trend.py:772: RuntimeWarning: invalid value encountered in double_scalars
df
| open | high | low | close | volume | volatility_bbm | volatility_bbh | volatility_bbl | trend_macd | momentum_rsi | volatility_kchi | trend_ichimoku_conv | trend_ichimoku_a | trend_ichimoku_b | momentum_stoch | momentum_stoch_signal | volatility_atr | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| timestamp | |||||||||||||||||
| 2016-08-10 15:53:00 | 579.00000 | 579.00 | 579.00000 | 579.00 | 1.000000 | 579.000000 | 579.000000 | 579.000000 | 0.000000 | 100.000000 | 0.0 | 579.000 | 579.000 | 579.000000 | 50.000000 | 50.000000 | 0.000000 |
| 2016-08-10 15:54:00 | 592.96000 | 604.75 | 592.96000 | 604.75 | 131.838200 | 591.875000 | 617.625000 | 566.125000 | 2.054131 | 100.000000 | 1.0 | 591.875 | 591.875 | 591.875000 | 100.000000 | 100.000000 | 0.000000 |
| 2016-08-10 15:55:00 | 604.75000 | 604.75 | 600.00000 | 600.00 | 89.437926 | 594.583333 | 616.960157 | 572.206510 | 3.261167 | 83.426791 | 1.0 | 591.875 | 591.875 | 591.875000 | 81.553398 | 90.776699 | 0.000000 |
| 2016-08-10 15:57:00 | 600.00000 | 604.75 | 600.00000 | 604.75 | 51.328200 | 597.125000 | 618.410265 | 575.839735 | 4.548603 | 85.936801 | 1.0 | 591.875 | 591.875 | 591.875000 | 100.000000 | 93.851133 | 0.000000 |
| 2016-08-10 15:58:00 | 604.75000 | 604.75 | 604.75000 | 604.75 | 4.586500 | 598.650000 | 618.641498 | 578.658502 | 5.505442 | 85.936801 | 1.0 | 591.875 | 591.875 | 591.875000 | 100.000000 | 93.851133 | 0.000000 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 2021-03-09 18:50:00 | 53725.00000 | 53727.00 | 53725.00000 | 53727.00 | 1.119537 | 53907.839382 | 54111.901593 | 53703.777170 | -57.400039 | 29.446404 | 0.0 | 53820.000 | 53860.750 | 53916.339746 | 0.884956 | 0.294985 | 33.719104 |
| 2021-03-09 18:51:00 | 53780.00000 | 53780.00 | 53779.00000 | 53779.00 | 0.010000 | 53893.539382 | 54091.537996 | 53695.540767 | -57.610695 | 37.411390 | 0.0 | 53820.000 | 53860.750 | 53916.339746 | 28.421053 | 9.768669 | 35.647194 |
| 2021-03-09 18:52:00 | 53814.00000 | 53828.00 | 53814.00000 | 53828.00 | 0.016450 | 53881.439382 | 54063.783077 | 53699.095686 | -53.210375 | 43.844695 | 1.0 | 53820.000 | 53860.750 | 53916.339746 | 54.210526 | 27.838845 | 36.982474 |
| 2021-03-09 18:53:00 | 53903.00000 | 53910.00 | 53902.00000 | 53910.00 | 0.012500 | 53874.711662 | 54041.774570 | 53707.648754 | -42.615134 | 52.621263 | 1.0 | 53820.000 | 53860.750 | 53916.339746 | 97.368421 | 60.000000 | 41.484227 |
| 2021-03-09 18:54:00 | 53930.36601 | 53958.00 | 53930.36601 | 53953.00 | 1.040000 | 53870.011662 | 54022.034074 | 53717.989250 | -30.398177 | 56.463846 | 1.0 | 53841.500 | 53871.500 | 53916.339746 | 97.854077 | 83.144342 | 42.135804 |
2270370 rows × 17 columns
df[::60].iplot(subplots=True)